<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,initial-scale=1.0,width=device-width" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>应聘列表</title>
    <link rel="stylesheet" type="text/css" href="../../../css/aui/aui.css" />
    <link rel="stylesheet" type="text/css" href="../../../css/html/order/get_work_frm.css" />
    <style>
        .btn {
            width: 4rem;
            margin-left: 0.2rem;
            line-height: 0.8rem;
            line-height: 0.8rem;
        }

        .iconimg {
            width: 0.6rem;
            display: inline-block;
        }

        .tab-content {
            margin-top: 3rem;
        }
    </style>
</head>

<body>
    <div id="app">
        <div class="tab_nav">
            <div class="aui-tab border_b" id="tab">
                <div class="aui-tab-item aui-active">专业用工类</div>
                <div class="aui-tab-item">零活类</div>
            </div>
        </div>
        <div class="tab-content">
            <div v-for="o,i in list" style="border-bottom:1px solid #eeeeee;margin-bottom:1rem;">
                <div class="aui-list" @click="details({id:o.work_id,isMobile:true})">
                    <div class="aui-list-item">
                        <div class="aui-list-item-inner">
                            <div class="aui-list-item-title aui-ellipsis-1">{{o.title}}</div>
                        </div>
                    </div>
                    <div class="aui-list-item">
                        <div class="aui-media-list-item-inner">
                            <!-- <div class="aui-list-item-media">
                                <img src="../../../image/portrait.png">
                            </div> -->
                            <div class="person_info">
                                <div> <img src="../../../image/icon/menu02-1.png" class="iconimg" alt=""> <span>联系人：{{o.contact}}</span></div>
                                <div> <img src="../../../image/icon/daohang.png" class="iconimg" alt=""> <span>项目地点：{{o.region}}</span></div>
                                <div> <img src="../../../image/icon/time.png" class="iconimg" alt=""> <span>发布时间：{{o.work_date}}</span></div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="btn-group" style="align-items:center;">
                    <div style="display:flex;">
                        <div class="btn" v-if="o.is_status===1" @click="theShelvesConfirm(o,i)">下架</div>
                        <div class="btn" v-else>已下架</div>
                        <div class="btn" @click="openWin(o,listType)">查看列表</div>
                    </div>
                </div>
            </div>

        </div>

    </div>
</body>
<script src="../../../script/api.js" charset="utf-8"></script>
<script src="../../../script/aui/aui-tab.js" charset="utf-8"></script>
<script src="../../../script/common/jquery-3.3.1.min.js" charset="utf-8"></script>
<script src="../../../script/common/common.js" charset="utf-8"></script>
<script src="../../../script/common/config.js" charset="utf-8"></script>
<script src="../../../script/common/vue.min.js" charset="utf-8"></script>
<script>
    apiready = function() {
        api.parseTapmode();
        vm.init();
    }

    var vm = new Vue({
        el: "#app",
        data: {
            userInfo: {},
            list: [],
            listType: 1,
            listPage: 1,
            listStatus: true,
        },
        methods: {
            init() {
                this.userInfo = get_local("userInfo");
                this.tabChange();
                this.upDownLoad();
                this.getList();
            },
            theShelvesConfirm(o, i) {
                var that = this;
                api.confirm({
                    title: '下架',
                    msg: '确认下架后，该条数据将不会展示在业务资源库！',
                    buttons: ['确定', '取消']
                }, function(ret, err) {
                    var index = ret.buttonIndex;
                    if (index === 1) {
                        that.theShelves(o, i);
                    }
                });
            },
            theShelves(o, index) {
                var that = this;
                var urls = {
                    1: Config.api.UserFoundCeaseUserSpecialty,
                    2: Config.api.UserFoundCeaseUserAmateur,
                };
                var data = {
                    user_id: that.userInfo.user_id,
                    work_id: o.work_id
                };
                _ajax(urls[that.listType], data, function(ret) {
                    if (ret.code === 200) {
                        // that.list.splice(index, 1);
                        that.list[index].is_status = 0;
                        $toast("下架成功");
                    }
                });
            },
            getList() {
                var that = this;
                var urls = {
                    1: Config.api.UserFoundUserSpecialty,
                    2: Config.api.UserFoundUserAmateur
                };
                var data = {
                    user_id: that.userInfo.user_id,
                    pages: that.listPage
                };

                _ajax(urls[that.listType], data, function(ret) {
                    if (ret.code === 200) {
                        if (that.listPage === 1) {
                            that.list = ret.data;
                        } else {
                            if (ret.data.length > 0) {
                                that.list = that.list.concat(ret.data);
                            } else {
                                that.listStatus = false;
                            }
                        }
                    }
                });
            },
            tabChange() {
                var that = this;
                var tab = new auiTab({
                    element: document.getElementById("tab"),
                    index: 1,
                    repeatClick: false
                }, function(ret) {
                    that.list = [];
                    that.listType = ret.index;
                    that.listPage = 1;
                    that.listStatus = true;
                    that.getList();
                });
            },
            upDownLoad() {
                var that = this;
                // 下拉刷新
                push_down(function() {
                    //下拉刷新恢复
                    push_down_over();

                    that.list = [];
                    that.listPage = 1;
                    that.listStatus = true;
                    that.getList();
                });

                //上拉加载
                push_up(function() {
                    if (that.listStatus) {
                        that.listPage++;
                        that.getList();
                    }
                });
            },
            openWin(o, type) {
                var name = 'apply_person_list_win';
                var url = './apply_person_list_win.html';
                open_w(name, url, {
                    work_id: o.work_id,
                    type: type
                });
            },
            details(o) {
                var winInfo = {
                    1: {
                        name: 'demand_details_new_win',
                        url: '../../details/demand_details_new_win.html',
                    },
                    2: {
                        name: "particulars_new_win",
                        url: "../../details/particulars_new_win.html"
                    },
                };
                open_w(winInfo[this.listType].name, winInfo[this.listType].url, o);
            }
        }
    });
</script>

</html>
